package com.kingsoft.demo.Observer;

import java.util.Observable;

/**
 * 被观察者
 * 
 * java.util.Observable是抽象被观察者 
 * @author kbl
 *
 */
public class Watched extends Observable{

	private String data; 
    public Watched(){ 
        data = ""; 
    } 
    public String retrieveData(){ 
        return data; 
    } 
    
    public void changeData(String data){ 
        if(data!=null && !this.data.equals(data)){ 
            String dt = this.data;//记录变化前的数据 
            this.data = data; 
            setChanged(); 
            notifyObservers(dt); 
        }        
    } 

	
}
